package org.liu.async.kit;

import java.util.concurrent.TimeUnit;

/**
 * Created by liuj on 2015/12/14.
 * 异步执行的配置
 */
public class AsyncConfig {

    /**
     * 方法的超时时间
     */
    private long timeout;
    /**
     *
     * 超时时间的单位
     */
    private TimeUnit timeUnit;
    /**
     * 是否异步
     */
    private boolean async = true;
    /**
     * 线程池的核心大小,maxCoreSize
     */
    private int coreSize = 10;
    /**
     * 线程池的队列大小
     */
    private int queueSize = 20;

    public AsyncConfig(long timeout, TimeUnit timeUnit) {
        this.timeout = timeout;
        this.timeUnit = timeUnit;
    }

    public AsyncConfig(long timeout, TimeUnit timeUnit, int queueSize, int coreSize, boolean async) {
        this.timeout = timeout;
        this.timeUnit = timeUnit;
        this.queueSize = queueSize;
        this.coreSize = coreSize;
        this.async = async;
    }

    public long getTimeout() {
        return timeout;
    }

    public void setTimeout(long timeout) {
        this.timeout = timeout;
    }

    public TimeUnit getTimeUnit() {
        return timeUnit;
    }

    public void setTimeUnit(TimeUnit timeUnit) {
        this.timeUnit = timeUnit;
    }

    public boolean isAsync() {
        return async;
    }

    public void setAsync(boolean async) {
        this.async = async;
    }

    public void setCoreSize(int coreSize) {
        this.coreSize = coreSize;
    }

    public void setQueueSize(int queueSize) {
        this.queueSize = queueSize;
    }

    public int getCoreSize() {
        return coreSize;
    }

    public int getQueueSize() {
        return queueSize;
    }
}
